package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhAddress;
import com.ruoyi.xh.service.IXhAddressService;

/**
 * 收获地址Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "收获地址Controller",value = "收获地址Controller")
@RestController
@RequestMapping("/xh/address")
public class XhAddressController extends BaseController {

    @Autowired
    private IXhAddressService xhAddressService;

    /**
     * 查询收获地址列表
     */
    @PreAuthorize("@ss.hasPermi('xh:address:list')")
    @GetMapping("/list")
    @ApiOperation("查询收获地址列表")
    public TablePageDataInfo<XhAddress> list(XhAddress xhAddress) {
        return TablePageDataInfo.success(xhAddressService.selectXhAddressList(xhAddress));
    }

    /**
     * 获取收获地址详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:address:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取收获地址详细信息")
    public CommentResult<XhAddress> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhAddressService.selectXhAddressById(id));
    }

    /**
     * 新增收获地址
     */
    @PreAuthorize("@ss.hasPermi('xh:address:add')")
    @Log(title = "收获地址", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增收获地址")
    public CommentResult<XhAddress> add(@RequestBody XhAddress xhAddress) {
            xhAddressService.insertXhAddress(xhAddress);
        return CommentResult.success();
    }

    /**
     * 修改收获地址
     */
    @PreAuthorize("@ss.hasPermi('xh:address:edit')")
    @Log(title = "收获地址", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改收获地址")
    public CommentResult<XhAddress> edit(@RequestBody XhAddress xhAddress) {
            xhAddressService.updateXhAddress(xhAddress);
        return CommentResult.success();
    }

    /**
     * 删除收获地址
     */
    @PreAuthorize("@ss.hasPermi('xh:address:remove')")
    @Log(title = "收获地址", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除收获地址")
    public CommentResult<XhAddress> remove(@PathVariable Long[] ids) {
            xhAddressService.deleteXhAddressByIds(ids);
        return CommentResult.success();
    }
}
